import tkinter as tk
from tkinter import ttk

root = tk.Tk()
root.title("Treeview 带图标示例")

# 创建图像对象
img1 = tk.PhotoImage(file='red_circle.png')  # 替换为你的图标路径
img2 = tk.PhotoImage(file='red_circle.png')  # 替换为你的图标路径

# 创建 Treeview
tree = ttk.Treeview(root, columns=('name', 'age'))
tree.heading('#0', text='ID')
tree.heading('name', text='姓名')
tree.heading('age', text='年龄')

# 插入带图标的项目
root1 = tree.insert('', 'end', text='1', image=img1, values=('张三', 25))
z=tree.insert(root1,'end', text='sub_1', image=img1, values=('张三', 25))



tree.insert('', 'end', text='2', image=img2, values=('李四', 30))

tree.pack(expand=True, fill='both')

root.mainloop()